﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DepartmentResposibilityUserControl.ascx.cs"
    Inherits="JM.JCY.SharePointComponent.Department.DepartmentResposibility.DepartmentResposibilityUserControl" %>
<script src="/_layouts/JM.JCY.Resource/TinyMCE/jscripts/tiny_mce/jquery.tinymce.js"
    type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {
        //ignore enter command
        $(function () {
            $("input[type=text]").keydown(function () {
                return (event.keyCode != 13);
            });
        });

        //for tinymce - custom richtexteditor
        $('textarea.tinymce').tinymce({
            // Location of TinyMCE script
            script_url: '/_layouts/JM.JCY.Resource/TinyMCE/jscripts/tiny_mce/tiny_mce.js',

            // General options
            theme: "advanced",
            plugins: "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

            // Theme options
            //theme_advanced_buttons1: "cut,copy,paste,removeformat,|,undo,redo,|,tablecontrols,|,link,unlink,image,code",
            theme_advanced_buttons2: "fontsizeselect,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,numlist,bullist,outdent,indent,|,forecolor,backcolor,ltr,rtl",
            theme_advanced_buttons3: "",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            //theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing: false,

            // Example content CSS (should be your site CSS)
            content_css: "css/content.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url: "lists/template_list.js",
            external_link_list_url: "lists/link_list.js",
            external_image_list_url: "lists/image_list.js",
            media_external_list_url: "lists/media_list.js"
        });


        LoadResp($("#<%=hfdeptId.ClientID %>").val());
    });


    function LoadResp(_deptId) {

        $.ajax({
            type: "GET",
            url: UserManagementServiceUrl + "GetResposibility?deptId=" + _deptId,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            success: function (result) {

                var JSON = eval('(' + (result) + ')');

                $("#ttaResp").val(JSON[0].deptResp);
                $("#displayContent").html(JSON[0].deptResp);

                $("#displayContent").show();
                $("#editContent").hide();

            },
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });

    }

    function UpdateResp(_deptId, _input) {

        var data = _input.replace('<p>', '');
        var dataFinal = data.replace('</p>', '');

        $.ajax({
            type: "GET",
            url: UserManagementServiceUrl + "UpdateDeptResposibility?deptId=" + _deptId + "&deptResp=" + dataFinal,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            success: function (result) {


                $("#displayContent").html(dataFinal);

            },
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });

    }

    function EditContent() {

        $("#displayContent").hide();
        $("#editContent").show();
        return false;
    }

    function SaveEdit() {

        // update data and display
        UpdateResp($("#<%=hfdeptId.ClientID %>").val(), $("#ttaResp").val());
        LoadResp($("#<%=hfdeptId.ClientID %>").val());
        $("#displayContent").show();
        $("#editContent").hide();

        return false;
    }

    function CancelEdit() {

        $("#displayContent").show();
        $("#editContent").hide();

        return false;
    }

</script>
<style type="text/css">
    .style1
    {
        text-align: right;
        padding-top: 10px;
        padding-right: 25px;
        width: 170px;
        font-family: 华文楷体;
        font-size: medium;
    }
    .style2
    {
        color: #0066CC;
        text-decoration: underline;
    }
    .style3
    {
        color: #0066CC;
    }
    .style4
    {
        font-family: 华文楷体;
    }
    .style5
    {
        font-size: small;
        font-family: 微软雅黑;
    }
    .style6
    {
        font-family: 华文楷体;
        font-size: medium;
        width: 100%;
    }
    .style7
    {
        font-size: 16px;
        font-weight: bold;
        text-align: center;
        padding-top: 9px;
        width: 80px;
        font-family: 华文楷体;
        color: #003366;
    }
    .style9
    {
        position: absolute;
        z-index: 21;
        right: 14px;
        top: 2px;
        width: 17px;
        height: 17px;
        font-size: 11px;
        color: #FF6600;
        text-align: center;
    }
    .style10
    {
        color: #999966;
    }
    .style16
    {
        font-family: 华文楷体;
        font-size: large;
        color: #003366;
    }
    .style17
    {
        font-family: 华文楷体;
        font-size: large;
        color: #800000;
    }
    .style19
    {
        font-family: 华文楷体;
        font-size: large;
        color: #000000;
    }
    .style20
    {
        font-family: 华文楷体;
        font-size: large;
        color: #CC3300;
    }
    .style21
    {
        height: 60px;
    }
    .style25
    {
        height: 20px;
        text-align: left;
    }
    .style27
    {
        font-family: 华文楷体;
        font-size: large;
    }
</style>
<table class="galleryHeader" width="100%">
    <tbody>
        <tr>
            <td class="style5">
                <asp:Label ID="lblDeptName" runat="server"></asp:Label>&nbsp;&nbsp;-&nbsp;&nbsp;
                工作职能
            </td>
            <td align="right">
                <asp:LinkButton ID="lkbEditResp" runat="server" Text="编辑" OnClientClick="return EditContent()">
                </asp:LinkButton>
            </td>
        </tr>
    </tbody>
</table>
<table>
    <tbody>
        <tr>
            <td valign="top" width="100%">
                <div id="displayContent">
                </div>
                <div id="editContent">
                    <textarea id="ttaResp" name="ttaResp" rows="10" cols="80" style="width: 100%" class="tinymce"></textarea>
                    <table>
                        <tr>
                            <td colspan="3" class="button">
                                <asp:ImageButton ID="imgSave" runat="server" ImageUrl="~/_layouts/JM.JCY.Resource/images/save.png"
                                    OnClientClick="return SaveEdit()" />
                                <asp:ImageButton ID="imgCancel" runat="server" ImageUrl="~/_layouts/JM.JCY.Resource/images/cancel.png"
                                    OnClientClick="return CancelEdit()" />
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </tbody>
</table>
<asp:HiddenField ID="hfdeptId" runat="server" />
